<?php
error_reporting(0);
include_once '../comm/config.php';
include_once '../comm/checkpostandget.php';
include_once '../comm/class.phpmailer.php';
include_once '../comm/wjt.php';
$tag="center";

$str=trim($_GET['str']); 
if($str==''){
	header('Location: error.php?id=18');
	exit;
}
$mingma_str=base64_decode($str);
$array_result = explode('@',$mingma_str);

$link = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$link) {
     die(ERR_DB);
}
mysql_select_db($dbname);
mysql_query("set names utf8");

$q = "SELECT * FROM ".$BIAOTOU."user where ddusername='".$array_result[0]."'";
$rs = mysql_query($q);
$total = mysql_num_rows($rs);
if($total==0)
{
	header('Location: error.php?id=3');
	exit;
}
else
{
	while($row = mysql_fetch_object($rs)) 
	{
		$ddusername=$row->ddusername; 
		$ddpassword=$row->ddpassword; 
	}
	$x = md5($ddusername.'+'.$ddpassword);
	if($x!=$array_result[1]){
		header('Location: error.php?id=19');
		exit;
	}
}     
mysql_close($link);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>找回密码 - 用户中心</title>
<link href="../css/usercss.css" rel="stylesheet" type="text/css">
<link href="../template/<?=MOBAN?>/css/common.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../js/jquery.js"></script>
<script language="javascript" type="text/javascript">
function getLength(str) {
    var len = str.length;
    var reLen = 0;
    for (var i = 0; i < len; i++) {        
        if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
            // 全角    
            reLen += 2;
        } else {
            reLen++;
        }
    }
    return reLen;    
} 
function checkpass(password)
{
    	if(getLength(password)<6 || getLength(password)>20)
		{
			document.getElementById("ckpass").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>密码长度必须为 6 - 20 位</font>';
		}
		else
		{
			document.getElementById("ckpass").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码填写正确</font>';
		}
}    

function checkpass2()
{
    	if(getLength(document.getElementById("password_check").value)<6 || getLength(document.getElementById("password_check").value)>20)
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>密码长度必须为 6 - 20 位</font>';
			return false;
		}
		else if (document.getElementById("password").value!=document.getElementById("password_check").value)
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>两次密码输入不一致！</font>';
			return false;
		}
		else
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码再次确认正确</font>';
			return true;
		}
}   
function checkall()
{
	if(document.getElementById("password").value==""||!checkpass2())
	{
		alert('请填写完内容！');
		return false;
	}
	else
	{
		return true;
	}
} 
</script>
</head>
<body>
<?php
include("../template/".MOBAN."/header.tpl.php");
?>
<?php
include("../template/".MOBAN."/nav.tpl.php");
?> 
<div id="maincenter">
  <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="50" align="left">&nbsp;</td>
  </tr>
  <tr>
    <td height="50" align="center"><img src="../images/step3.gif" alt="找回密码第三步" width="637" height="31" /></td>
  </tr>
  <tr>
    <td height="146" align="center">  <form id="form1" name="form1" method="post" action="save_resetpass.php" onsubmit="return checkall()"><table width="500" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="165" height="35" align="right">&nbsp;</td>
        <td height="35" colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td height="35" align="right">请输入新的密码：</td>
        <td width="147" height="35" align="left"><label>
          <input name="password" type="password" id="password"  onblur="checkpass(document.getElementById('password').value);" size="20" maxlength="20" style="width:130px;" class="ddinput"/>
        </label></td>
        <td width="188" height="35" align="left" id="ckpass">&nbsp;</td>
      </tr>
      <tr>
        <td height="35" align="right">请再次输入密码：</td>
        <td height="35" align="left"><label>
          <input name="password2" type="password" id="password_check" onblur="checkpass2();"  size="20" maxlength="20" style="width:130px;" class="ddinput"/>
        </label></td>
        <td height="35" align="left" id="ckpass2">&nbsp;</td>
      </tr>
      <tr>
        <td height="35" align="right">&nbsp;</td>
        <td height="35" align="left">
          <input type="submit" name="Submit" value="重置密码" class="ddbutton"/>
          <input type="hidden" name="ddusername" value="<?=$array_result[0]?>" /></td>
        <td height="35" align="left">&nbsp;</td>
      </tr>
    </table>
    
      </form>
      </td>
  </tr>
  <tr>
    <td height="50" align="center" style="font-size:14px"></td>
  </tr>
</table>
</div>
<?php
include("../template/".MOBAN."/footer.tpl.php");
?>
</body>
</html>